﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;

namespace GPCSC.Web.WBWZ
{
    public partial class xix : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
              if (!IsPostBack)
            {
                try
                {
                    buildTZGG();
                    buildGZJB();
                }
                catch (Exception ee)
                {
                    throw ee;
                }
            }
        }
        protected void buildTZGG()
        {
            Hashtable htable = new Hashtable();

            htable.Add("BTSBLMName", "2");
            DataSet ds = new DataReturn().ReturnData(htable, "sel_sydtxw_all");
            if (ds != null)
            {

                tzgg.DataSource = cutTitle(ds);
                tzgg.DataBind();
            }
        }
        //绑定工作简报
        protected void buildGZJB()
        {
            //Hashtable htable = new Hashtable();

            //htable.Add("BTSBLMName", "5");
            //DataSet ds = new DataReturn().ReturnData(htable, "sel_sydtxw_all");
            //if (ds != null)
            //{

            //    gzjb.DataSource = cutTitle(ds);
            //    gzjb.DataBind();

            //}
            Hashtable htable = new Hashtable();
            DataSet ds = new DataReturn().ReturnData(htable, "sel_mqlists_to");
            if (ds != null)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    dr["NewsID"] = dr["tabids"].ToString();
                    if (dr["mqtitle"].ToString().Length > 18)
                    {
                        dr["showtitle"] = dr["mqtitle"].ToString().Substring(0, 18) + "...";
                    }
                    else
                    {
                        dr["showtitle"] = dr["mqtitle"].ToString();
                    }
                    dr["FBdate"] = Usual.f_convertDateTime(dr["mqdate"].ToString()).ToShortDateString();
                    dr["BTSBLMName"] = "6";
                }
                gzjb.DataSource = ds;
                gzjb.DataBind();
            }
        }
        /// <summary>
        /// 若标题过长  截取标题
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        protected DataSet cutTitle(DataSet ds)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["NewsTitles"].ToString().Length > 16)
                    {
                        dr["showtitle"] = dr["NewsTitles"].ToString().Substring(0, 16) + "...";
                    }
                    else
                    {
                        dr["showtitle"] = dr["NewsTitles"].ToString();
                    }
                }
            }
            return ds;
        }
    }
}